package com.redpixy.monit.mail;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.redpixy.monit.common.param.MailParam;

public class MailSender {

	public static final Logger log = LoggerFactory.getLogger(MailSender.class);
	public static void sendMail(String title, String context, String[] to) {
		for (int i = 0; i < to.length; i++) {
			sendMail(title,  context,  to[i]);
		}
	}
	public static void sendMail(String title, String context, String to) {
		try {
			MailSenderInfo mailInfo = new MailSenderInfo();
			mailInfo.setMailServerHost(MailParam.MAILSERVERHOST);
			mailInfo.setMailServerPort(MailParam.MAILSERVERPORT);
			mailInfo.setValidate(true);
			mailInfo.setUserName(MailParam.USERNAME);
			mailInfo.setPassword(MailParam.PASSWORD);// 您的邮箱密码
			mailInfo.setFromAddress(MailParam.FROMADDRESS);
			mailInfo.setToAddress(to);
			mailInfo.setSubject(title);
			mailInfo.setContent(context);
			// 这个类主要来发送邮件　　
			SimpleMailSender sms = new SimpleMailSender();
			sms.sendHtmlMail(mailInfo);// 发送html格式　
		} catch (Exception e) {
			log.error("", e);
		}
		
	}
}
